<div id="activity_template" data-bind="foreach: activity_items">
    <img onerror="imgerror(this)" class="activity_image" data-bind="attr : { src : pic , link : link , goods_name : goods_name , des : des}" alt="">
</div>

<script>
    function activity_template() {
        var items = <?php echo json_encode($items)?>;
        this.activity_items = ko.observableArray([]);
        var self = this;
        items.forEach(function (item) {
            self.activity_items.push(new activity_item(item.pic,item.link,item.goods_name,item.des))
        })
    }

    function activity_item(pic,link,goods_name,des) {
        this.pic = ko.observable(pic);
        this.link = ko.observable(link);
        this.goods_name = ko.observable(goods_name);
        this.des = ko.observable(des);
    }


    ko.applyBindings(new activity_template(), $('#activity_template')[0]);

</script>
